﻿using UnityEngine;
using System.Collections;

public class thirdPersonCamera : MonoBehaviour {

	public float distanceAway;
	public float distanceUP=3;
	public float smooth;
	public float cameraVerticalLimitDown;
	public float cameraVerticalLimitUP;
	public float cameraVelocity;
	public float shootingDistance;
	public float platformingDistance;


	private Transform follow;
	private Transform shootingTarget;
	private Vector3 targetPosition;
	private bool aiming=false;

	// Use this for initialization
	void Start () 
	{
		follow = GameObject.FindWithTag ("CameraTarget").transform;
		shootingTarget = GameObject.FindWithTag ("ShootingTarget").transform;
	}
	
	// Update is called once per frame
	void FixedUpdate () 
	{


		if(Input.GetKey(KeyCode.UpArrow))
		{
			if(distanceUP<=cameraVerticalLimitUP)
				distanceUP+=cameraVelocity;
		}
		else if(Input.GetKey(KeyCode.DownArrow))
		{
			if(distanceUP>=cameraVerticalLimitDown)
				distanceUP-=cameraVelocity;
		}




		transform.LookAt (follow);


		targetPosition = follow.position + follow.up * distanceUP - follow.forward * distanceAway;
		transform.position = Vector3.Lerp (transform.position , targetPosition,Time.deltaTime * smooth);


	}
}
